use std::{path::Path, fs};

fn main() {
    let lua_path = Path::new("./lua");
    let lua_sources = fs::read_dir(lua_path)
        .unwrap()
        .map(|entry| entry.unwrap().path())
        .filter(|path| path.extension().is_some_and(|ext| ext.to_ascii_lowercase() == "c"));
    
    cc::Build::new()
        .files(lua_sources)
        .include(lua_path)
        .compile("lua");
    
    println!("cargo:rerun-if-changed=build.rs")
}